package com.zuul.filter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;
import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
import org.springframework.stereotype.Component;


import javax.servlet.http.HttpServletRequest;

@Component
public class zuulFilter extends ZuulFilter {


    @Override
    public String filterType() {
        // 过滤器类型
        // 执行前过滤 pre
        // 执行后过滤 post
        return FilterConstants.PRE_TYPE;
    }

    @Override
    public int filterOrder() {
        // 0 优先执行
        // 数字越小先执行
        return 0;
    }

    @Override
    public boolean shouldFilter() {
        // 过滤器是否开启
        return true;
    }

    @Override
    public Object run() throws ZuulException {
        // 过滤器 过滤的内容
        // retuen 任何object的值
        // setsendzuulResponse(false)表示不在执行
        System.out.println("经过后台过滤器");

        RequestContext requestContext = RequestContext.getCurrentContext();

        HttpServletRequest request = requestContext.getRequest();


        return null;
    }
}
